package com.example.controller;

import com.example.pojo.Result;
import com.example.util.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@Slf4j
@RestController
public class UploadController {
    @Autowired
    AliOSSUtils aliOSSUtils;
    /**
     * 上传图片
     */
    @PostMapping("/upload")
    public Result upload(MultipartFile file) throws IOException {
        log.info("上传图片到OSS");
        String Url=aliOSSUtils.upload(file);

        log.info("上传完成，访问路径{}", Url);

        return Result.success(Url);
    }
}
